{% extends "base.html" %}
{% block title %} 系统参数配置 {% endblock %}

{% block content %}
<br />
<div>
<form name="configForm" id="configForm" method="post" action="/config/">
<input type="hidden" id="oldKey" value="" />
<input type="hidden" id="oldValue" value="" />
<table border="1" cellspacing="0" cellpadding="0" style="font-size:20px">
<tr>
<th>SID</td>
<th>名称Key</td>
<th>值Value</td>
<th>删除</th>
</tr>
{% for config in configs %}
<tr>
<td align="center"><a href="#" id="a{{config.sid}}">选择</a></td>
<script type="text/javascript">
$("#a{{config.sid}}").click(function() {
	$("#newKey").attr("value", $("#key{{config.sid}}").val())
	$("#newValue").attr("value", $("#value{{config.sid}}").val())
	
	$("#oldKey").attr("value", $("#key{{config.sid}}").val())
	$("#oldValue").attr("value", $("#value{{config.sid}}").val())	
});
</script>
<td><input type="hidden" id="key{{config.sid}}" name="key{{config.sid}}"  value="{{config.name}}"/>{{config.name}}</td>
<td><input type="hidden" id="value{{config.sid}}" name="value{{config.sid}}" value="{{config.value}}"/>{{config.value}}</td>
<td><a href="/config/delete/{{config.sid}}">删除</a>
</tr>
{% endfor %}
<tr>
<th colspan="1">名称Key</th> 
<th colspan="3">值Value</th>
</tr>
<tr>
<th colspan="1"><input type="text" id="newKey" name="newKey" /></th>
<th colspan="3"><input type="text" id="newValue" name="newValue" style="width:100%" /></th>
</tr>
<tr>
<td colspan="1">&nbsp;</td>
<td colspan="3"><input type="button" value="添加或更新" id="btnAddOrUpdate" />
</tr>
</table>
<script type="text/javascript">
$("#btnAddOrUpdate").click(function(){
	if( $("#newKey").val() == $("#oldKey").val()  && $("#newValue").val() == $("#oldValue").val()) {
		alert("您没有做任何改变");
		return;
	} else {
		//alert("submited");
		$("#configForm").submit();
		
	}
});
</script>

</form>


</div>

{% endblock %}